package codetop.microsoft.T384;

import java.util.Random;

/**
 * @Author: 18362
 * @Create: 2022-09-06 0:34:20 星期二
 */
class Solution {

    private int[] nums;
    private Random random = new Random();

    public Solution(int[] nums) {
        this.nums = nums;
    }

    public int[] reset() {
        return nums;
    }

    public int[] shuffle() {
        int[] temp = nums.clone();
        for (int i=0; i<nums.length; ++i) {
            int j = i + random.nextInt(nums.length - i);
            swap(temp, i, j);
        }
        return temp;
    }

    private void swap(int[] arr, int x, int y) {
        int temp = arr[x];
        arr[x] = arr[y];
        arr[y] = temp;
    }
}